<?php
/**
 * Medical Center - Monitoring Summary 
 * This module will display the current medical center monitoring it
 * cannot be updated
 * 
 * @author Xavier VILAIN
 * @package Nawa\MedicalStudy\MedicalCenter\Monitoring
 * @license #license-nawa#
 * 
 */

use Fox\Html\Separator;
use Fox\Generator;
use Nawa\MedicalStudy\MedicalCenter\Monitoring;
use Fox\Html\Screen;
$xview = Xview::instance();
$msid = $xview->val('msid');
$mcid = $xview->val('mcid');
$monitoringid = $xview->val('monitoringid');
$mode = $xview->val('mode');
$keys = array('msid' => $msid,'mcid' => $mcid);
$ms = $xview->component('medicalstudies','object',$keys);
$nbCenters = $ms->countMedicalCentersPartners();
$centerPartner = $ms->findMedicalCentersPartners($msid.':'.$mcid);
$medicalCenter = $centerPartner->medicalCenter();
$data['gMonitorings'] = $centerPartner->monitorings();
// Bread Crumb
$crumbs = Xview::instance()
	->component('medicalstudies','breadcrumb',
	array('deepness' => 4,
		  'customerid' => $ms->customer()->getId(),
		  'customer_name' => $ms->customer()->name1,
		  'msReference' => $ms->reference,
		  'msid' => $ms->getId(),
		  'msCenterCount' => $nbCenters,
		  'mcid' => $mcid,
		  'mcLabel' => $medicalCenter->label(),
		  'mcMonitoringCount' => $centerPartner->countMonitorings(),
		  'type' => Monitoring::BREADCRUMB_NODE
	)
);
$screen = new Screen('sCenter');
$screen->breadcrumb()->crumbs($crumbs);
$screen->add(new Separator('s'));
// Monitorings
$gMonitorings = $xview->module(Generator::url('medicalstudies','medicalcenters', 'monitorings',$keys));
$screen->add($gMonitorings);
$screen->initialize($data);
// Display All Monitorings
if($screen->submitted()) {
	$fields = $screen->get();
	if(!$screen->errors())
	{
		try {
			
		}
		catch (Fox\Object\Exception\Save $e)
		{
			Fox\Message::Error($e);
		}
	}
}
echo $screen->display();